package com.zxl.app.context;

import com.zxl.common.model.pojo.SysMember;
import com.zxl.common.model.query.AppletsTokenMemberInfo;


/**
 * @author zxw
 * @date 2023/3/30
 */
public class UserContext {

    private static final ThreadLocal<Integer> userHolder = new ThreadLocal();
    private static final ThreadLocal<AppletsTokenMemberInfo> userInfoHolder = new ThreadLocal();
    private static final ThreadLocal<SysMember> memberHolder = new ThreadLocal<>();


    public static SysMember getUser(){
        return memberHolder.get();
    }

    public static void setUser(SysMember member){
        memberHolder.set(member);
    }

    public static AppletsTokenMemberInfo getUserInfo() {
        return userInfoHolder.get();
    }

    public static Integer getUserId() {
        return userHolder.get();
    }

    public static void setUserId(Integer userId) {
        userHolder.set(userId);
    }

    public static void setUserInfo(AppletsTokenMemberInfo member) {
        userInfoHolder.set(member);
    }


    public static void clearContext() {
        userInfoHolder.remove();
        userHolder.remove();
        memberHolder.remove();
    }

}

